//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.family;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import org.jpgolay.gui.fixed.TableViewer;
import org.jpgolay.me.persistence.IfExist;
import org.jpgolay.me.persistence.ObjectCRUD;
import org.jpgolay.me.util.MEUtility;
import org.jpgolay.me.util.Parameter;

// Referenced classes of package org.jpgolay.me.family:
//            FamilyGUI, Family
public class FamilyController extends FamilyGUI {

    public FamilyController(Parameter param) {
        updateTable = true;
        write = false;
        this.param = param;
        crud = new ObjectCRUD();
        ifExist = new IfExist();
        initLaw();
        initItemTable();
        initCustomerTable();
        initSupplierTable();
        initSalesPersonTable();
        initItemTableValues();
        initCustomerTableValues();
        initSupplierTableValues();
        initSalesPersonTableValues();
    }

    private void initLaw() {
        if (param.getAccessLaw().length() >= 11 && param.getAccessLaw().charAt(11) == '1') {
            write = true;
        }
    }

    private void initItemTable() {
        getItemTable().setTypes(new Class[]{
                    java.lang.String.class, java.lang.String.class, java.math.BigDecimal.class
                });
        getItemTable().setLastColumnNotEditable(-1);
        getItemTable().setCellEditable(write);
        getItemTable().setAlternateColor(MEUtility.ITEM_LINE);
        getItemTable().setColumnNames(new String[]{
                    "CODE", "DESIGNATION", "COEFFICIENT"
                });
        getItemTable().setPreferredColumnSize(new int[]{
                    50, 150, 50
                });
    }

    private void initCustomerTable() {
        getCustomerTable().setTypes(new Class[]{
                    java.lang.String.class, java.lang.String.class, java.math.BigDecimal.class
                });
        getCustomerTable().setLastColumnNotEditable(-1);
        getCustomerTable().setCellEditable(write);
        getCustomerTable().setAlternateColor(MEUtility.CUSTOMER_LINE);
        getCustomerTable().setColumnNames(new String[]{
                    "CODE", "DESIGNATION", "COEFFICIENT"
                });
        getCustomerTable().setPreferredColumnSize(new int[]{
                    50, 150, 50
                });
    }

    private void initSupplierTable() {
        getSupplierTable().setTypes(new Class[]{
                    java.lang.String.class, java.lang.String.class, java.math.BigDecimal.class
                });
        getSupplierTable().setLastColumnNotEditable(-1);
        getSupplierTable().setCellEditable(write);
        getSupplierTable().setAlternateColor(MEUtility.SUPPLIER_LINE);
        getSupplierTable().setColumnNames(new String[]{
                    "CODE", "DESIGNATION", "COEFFICIENT"
                });
        getSupplierTable().setPreferredColumnSize(new int[]{
                    50, 150, 50
                });
    }

    private void initSalesPersonTable() {
        getSalesPersonTable().setTypes(new Class[]{
                    java.lang.String.class, java.lang.String.class, java.math.BigDecimal.class
                });
        getSalesPersonTable().setLastColumnNotEditable(-1);
        getSalesPersonTable().setCellEditable(write);
        getSalesPersonTable().setAlternateColor(MEUtility.SALES_PERSON_LINE);
        getSalesPersonTable().setColumnNames(new String[]{
                    "CODE", "DESIGNATION", "COEFFICIENT"
                });
        getSalesPersonTable().setPreferredColumnSize(new int[]{
                    50, 150, 50
                });
    }

    private void initItemTableValues() {
        Object data[][] = (Object[][]) null;
        java.util.Collection list = crud.readAll(null, 12);
        if (list != null) {
            Family family = null;
            itemFamilyList = new ArrayList(list);
            data = new Object[itemFamilyList.size() + 5][3];
            Iterator it = itemFamilyList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i][0] = family.getId();
                data[i][1] = family.getDesignation();
                data[i][2] = family.getCoefficient().setScale(param.getMinimumDecimalNumber().intValue(), param.getRoundType().intValue());
            }

            for (int i = itemFamilyList.size(); i < itemFamilyList.size() + 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        } else {
            data = new Object[5][3];
            for (int i = 0; i < 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        }
        getItemTable().setData(data);
        getItemTable().getTableModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (updateTable) {
                    actionUpdateItemFamily(e.getFirstRow());
                }
            }
        });
    }

    private void initCustomerTableValues() {
        Object data[][] = (Object[][]) null;
        java.util.Collection list = crud.readAll(null, 46);
        if (list != null) {
            Family family = null;
            customerFamilyList = new ArrayList(list);
            data = new Object[customerFamilyList.size() + 5][3];
            Iterator it = customerFamilyList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i][0] = family.getId();
                data[i][1] = family.getDesignation();
                data[i][2] = family.getCoefficient().setScale(param.getMinimumDecimalNumber().intValue(), param.getRoundType().intValue());
            }

            for (int i = customerFamilyList.size(); i < customerFamilyList.size() + 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        } else {
            data = new Object[5][3];
            for (int i = 0; i < 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        }
        getCustomerTable().setData(data);
        getCustomerTable().getTableModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (updateTable) {
                    actionUpdateCustomerFamily(e.getFirstRow());
                }
            }
        });
    }

    private void initSupplierTableValues() {
        Object data[][] = (Object[][]) null;
        java.util.Collection list = crud.readAll(null, 10);
        if (list != null) {
            Family family = null;
            supplierFamilyList = new ArrayList(list);
            data = new Object[supplierFamilyList.size() + 5][3];
            Iterator it = supplierFamilyList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i][0] = family.getId();
                data[i][1] = family.getDesignation();
                data[i][2] = family.getCoefficient().setScale(param.getMinimumDecimalNumber().intValue(), param.getRoundType().intValue());
            }

            for (int i = supplierFamilyList.size(); i < supplierFamilyList.size() + 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        } else {
            data = new Object[5][3];
            for (int i = 0; i < 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        }
        getSupplierTable().setData(data);
        getSupplierTable().getTableModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (updateTable) {
                    actionUpdateSupplierFamily(e.getFirstRow());
                }
            }
        });
    }

    private void initSalesPersonTableValues() {
        Object data[][] = (Object[][]) null;
        java.util.Collection list = crud.readAll(null, 39);
        if (list != null) {
            Family family = null;
            salesPersonFamilyList = new ArrayList(list);
            data = new Object[salesPersonFamilyList.size() + 5][3];
            Iterator it = salesPersonFamilyList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i][0] = family.getId();
                data[i][1] = family.getDesignation();
                data[i][2] = family.getCoefficient().setScale(param.getMinimumDecimalNumber().intValue(), param.getRoundType().intValue());
            }

            for (int i = salesPersonFamilyList.size(); i < salesPersonFamilyList.size() + 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        } else {
            data = new Object[5][3];
            for (int i = 0; i < 5; i++) {
                data[i][0] = null;
                data[i][1] = null;
                data[i][2] = null;
            }

        }
        getSalesPersonTable().setData(data);
        getSalesPersonTable().getTableModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (updateTable) {
                    actionUpdateSalesPersonFamily(e.getFirstRow());
                }
            }
        });
    }

    private void actionUpdateItemFamily(int row) {
        if (row >= itemFamilyList.size()) {
            if ((String) getItemTable().getTable().getValueAt(row, 0) == null) {
                JOptionPane.showMessageDialog(null, "Le code famille n'est pas saisi !");
                updateTable = false;
                getItemTable().getTable().setValueAt(null, row, 2);
                getItemTable().getTable().setValueAt(null, row, 1);
                updateTable = true;
            } else {
                actionNewItemFamily(row);
            }
        } else {
            Family oldFamily = (Family) itemFamilyList.get(row);
            if (oldFamily.getId().equals((String) getItemTable().getTable().getValueAt(row, 0))) {
                if (getItemTable().getTable().getValueAt(row, 2) != null) {
                    oldFamily.setCoefficient((BigDecimal) getItemTable().getTable().getValueAt(row, 2));
                }
                if (getItemTable().getTable().getValueAt(row, 1) != null) {
                    oldFamily.setDesignation((String) getItemTable().getTable().getValueAt(row, 1));
                }
                oldFamily.setUpdateUserId(param.getUserId());
                crud.update(oldFamily, 12);
                oldFamily = (Family) crud.read(oldFamily.getId(), 12);
                if (oldFamily != null) {
                    itemFamilyList.set(row, oldFamily);
                }
            } else if (crud.create(12, (String) getItemTable().getTable().getValueAt(row, 0)) == null) {
                JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
                updateTable = false;
                getItemTable().getTable().setValueAt(null, row, 0);
                updateTable = true;
            } else {
                Family f = (Family) crud.read((String) getItemTable().getTable().getValueAt(row, 0), 12);
                if (f != null) {
                    if (getItemTable().getTable().getValueAt(row, 2) != null) {
                        f.setCoefficient((BigDecimal) getItemTable().getTable().getValueAt(row, 2));
                    }
                    if (getItemTable().getTable().getValueAt(row, 1) != null) {
                        f.setDesignation((String) getItemTable().getTable().getValueAt(row, 1));
                    }
                    f.setUpdateUserId(param.getUserId());
                    crud.update(f, 12);
                    f = (Family) crud.read(f.getId(), 12);
                    if (f != null) {
                        itemFamilyList.set(row, f);
                    }
                    if (crud.delete(oldFamily.getId(), oldFamily.getUpdateTime(), 12)) {
                        actionCascadeUpdateItem(oldFamily.getId(), (String) getItemTable().getTable().getValueAt(row, 0));
                    }
                }
            }
        }
    }

    private void actionCascadeUpdateItem(String oldPK, String newPK) {
        crud.update(oldPK, newPK, 11);
    }

    private void actionNewItemFamily(int row) {
        if (crud.create(12, (String) getItemTable().getTable().getValueAt(row, 0)) == null) {
            JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
            updateTable = false;
            getItemTable().getTable().setValueAt(null, row, 0);
            updateTable = true;
        } else {
            Family f = (Family) crud.read((String) getItemTable().getTable().getValueAt(row, 0), 12);
            if (f != null) {
                f.setCoefficient(new BigDecimal("0.00"));
                f.setDesignation(f.getId() + " (defaut)");
                f.setUpdateUserId(param.getUserId());
                crud.update(f, 12);
                f = (Family) crud.read(f.getId(), 12);
                if (f != null) {
                    itemFamilyList.add(f);
                }
                initItemTableValues();
            }
        }
    }

    private void actionDeleteItemFamily(int row) {
        int response = JOptionPane.showConfirmDialog(null, "Etes-vous certain de vouloir suprimer cette famille ?", "Confirmation", 1, 2, null);
        switch (response) {
            case -1:
            case 0: // '\0'
            case 1: // '\001'
            case 2: // '\002'
            default:
                return;
        }
    }

    private void actionUpdateCustomerFamily(int row) {
        if (row >= customerFamilyList.size()) {
            if ((String) getCustomerTable().getTable().getValueAt(row, 0) == null) {
                JOptionPane.showMessageDialog(null, "Le code famille n'est pas saisi !");
                updateTable = false;
                getCustomerTable().getTable().setValueAt(null, row, 2);
                getCustomerTable().getTable().setValueAt(null, row, 1);
                updateTable = true;
            } else {
                actionNewCustomerFamily(row);
            }
        } else {
            Family oldFamily = (Family) customerFamilyList.get(row);
            if (oldFamily.getId().equals((String) getCustomerTable().getTable().getValueAt(row, 0))) {
                if (getCustomerTable().getTable().getValueAt(row, 2) != null) {
                    oldFamily.setCoefficient((BigDecimal) getCustomerTable().getTable().getValueAt(row, 2));
                }
                if (getCustomerTable().getTable().getValueAt(row, 1) != null) {
                    oldFamily.setDesignation((String) getCustomerTable().getTable().getValueAt(row, 1));
                }
                oldFamily.setUpdateUserId(param.getUserId());
                crud.update(oldFamily, 46);
                oldFamily = (Family) crud.read(oldFamily.getId(), 46);
                if (oldFamily != null) {
                    customerFamilyList.set(row, oldFamily);
                }
            } else if (crud.create(46, (String) getCustomerTable().getTable().getValueAt(row, 0)) == null) {
                JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
                updateTable = false;
                getCustomerTable().getTable().setValueAt(null, row, 0);
                updateTable = true;
            } else {
                Family f = (Family) crud.read((String) getCustomerTable().getTable().getValueAt(row, 0), 46);
                if (f != null) {
                    if (getCustomerTable().getTable().getValueAt(row, 2) != null) {
                        f.setCoefficient((BigDecimal) getCustomerTable().getTable().getValueAt(row, 2));
                    }
                    if (getCustomerTable().getTable().getValueAt(row, 1) != null) {
                        f.setDesignation((String) getCustomerTable().getTable().getValueAt(row, 1));
                    }
                    f.setUpdateUserId(param.getUserId());
                    crud.update(f, 46);
                    f = (Family) crud.read(f.getId(), 46);
                    if (f != null) {
                        customerFamilyList.set(row, f);
                    }
                    if (crud.delete(oldFamily.getId(), oldFamily.getUpdateTime(), 46)) {
                        actionCascadeUpdateCustomer(oldFamily.getId(), (String) getCustomerTable().getTable().getValueAt(row, 0));
                    }
                }
            }
        }
    }

    private void actionCascadeUpdateCustomer(String oldPK, String newPK) {
        crud.update(oldPK, newPK, 27);
    }

    private void actionNewCustomerFamily(int row) {
        if (crud.create(46, (String) getCustomerTable().getTable().getValueAt(row, 0)) == null) {
            JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
            updateTable = false;
            getCustomerTable().getTable().setValueAt(null, row, 0);
            updateTable = true;
        } else {
            Family f = (Family) crud.read((String) getCustomerTable().getTable().getValueAt(row, 0), 46);
            if (f != null) {
                f.setCoefficient(new BigDecimal("0.00"));
                f.setDesignation(f.getId() + " (defaut)");
                f.setUpdateUserId(param.getUserId());
                crud.update(f, 46);
                f = (Family) crud.read(f.getId(), 46);
                if (f != null) {
                    customerFamilyList.add(f);
                }
                initCustomerTableValues();
            }
        }
    }

    private void actionDeleteCustomerFamily(int row) {
        int response = JOptionPane.showConfirmDialog(null, "Etes-vous certain de vouloir suprimer cette famille ?", "Confirmation", 1, 2, null);
        switch (response) {
            case -1:
            case 0: // '\0'
            case 1: // '\001'
            case 2: // '\002'
            default:
                return;
        }
    }

    private void actionUpdateSupplierFamily(int row) {
        if (row >= supplierFamilyList.size()) {
            if ((String) getSupplierTable().getTable().getValueAt(row, 0) == null) {
                JOptionPane.showMessageDialog(null, "Le code famille n'est pas saisi !");
                updateTable = false;
                getSupplierTable().getTable().setValueAt(null, row, 2);
                getSupplierTable().getTable().setValueAt(null, row, 1);
                updateTable = true;
            } else {
                actionNewSupplierFamily(row);
            }
        } else {
            Family oldFamily = (Family) supplierFamilyList.get(row);
            if (oldFamily.getId().equals((String) getSupplierTable().getTable().getValueAt(row, 0))) {
                if (getSupplierTable().getTable().getValueAt(row, 2) != null) {
                    oldFamily.setCoefficient((BigDecimal) getSupplierTable().getTable().getValueAt(row, 2));
                }
                if (getSupplierTable().getTable().getValueAt(row, 1) != null) {
                    oldFamily.setDesignation((String) getSupplierTable().getTable().getValueAt(row, 1));
                }
                oldFamily.setUpdateUserId(param.getUserId());
                crud.update(oldFamily, 10);
                oldFamily = (Family) crud.read(oldFamily.getId(), 10);
                if (oldFamily != null) {
                    supplierFamilyList.set(row, oldFamily);
                }
            } else if (crud.create(10, (String) getSupplierTable().getTable().getValueAt(row, 0)) == null) {
                JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
                updateTable = false;
                getSupplierTable().getTable().setValueAt(null, row, 0);
                updateTable = true;
            } else {
                Family f = (Family) crud.read((String) getSupplierTable().getTable().getValueAt(row, 0), 10);
                if (f != null) {
                    if (getSupplierTable().getTable().getValueAt(row, 2) != null) {
                        f.setCoefficient((BigDecimal) getSupplierTable().getTable().getValueAt(row, 2));
                    }
                    if (getSupplierTable().getTable().getValueAt(row, 1) != null) {
                        f.setDesignation((String) getSupplierTable().getTable().getValueAt(row, 1));
                    }
                    f.setUpdateUserId(param.getUserId());
                    crud.update(f, 10);
                    f = (Family) crud.read(f.getId(), 10);
                    if (f != null) {
                        supplierFamilyList.set(row, f);
                    }
                    if (crud.delete(oldFamily.getId(), oldFamily.getUpdateTime(), 10)) {
                        actionCascadeUpdateSupplier(oldFamily.getId(), (String) getSupplierTable().getTable().getValueAt(row, 0));
                    }
                }
            }
        }
    }

    private void actionCascadeUpdateSupplier(String oldPK, String newPK) {
        crud.update(oldPK, newPK, 9);
    }

    private void actionNewSupplierFamily(int row) {
        if (crud.create(10, (String) getSupplierTable().getTable().getValueAt(row, 0)) == null) {
            JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
            updateTable = false;
            getSupplierTable().getTable().setValueAt(null, row, 0);
            updateTable = true;
        } else {
            Family f = (Family) crud.read((String) getSupplierTable().getTable().getValueAt(row, 0), 10);
            if (f != null) {
                f.setCoefficient(new BigDecimal("0.00"));
                f.setDesignation(f.getId() + " (defaut)");
                f.setUpdateUserId(param.getUserId());
                crud.update(f, 10);
                f = (Family) crud.read(f.getId(), 10);
                if (f != null) {
                    supplierFamilyList.add(f);
                }
                initSupplierTableValues();
            }
        }
    }

    private void actionDeleteSupplierFamily(int row) {
        int response = JOptionPane.showConfirmDialog(null, "Etes-vous certain de vouloir suprimer cette famille ?", "Confirmation", 1, 2, null);
        switch (response) {
            case -1:
            case 0: // '\0'
            case 1: // '\001'
            case 2: // '\002'
            default:
                return;
        }
    }

    private void actionUpdateSalesPersonFamily(int row) {
        if (row >= salesPersonFamilyList.size()) {
            if ((String) getSalesPersonTable().getTable().getValueAt(row, 0) == null) {
                JOptionPane.showMessageDialog(null, "Le code famille n'est pas saisi !");
                updateTable = false;
                getSalesPersonTable().getTable().setValueAt(null, row, 2);
                getSalesPersonTable().getTable().setValueAt(null, row, 1);
                updateTable = true;
            } else {
                actionNewSalesPersonFamily(row);
            }
        } else {
            Family oldFamily = (Family) salesPersonFamilyList.get(row);
            if (oldFamily.getId().equals((String) getSalesPersonTable().getTable().getValueAt(row, 0))) {
                if (getSalesPersonTable().getTable().getValueAt(row, 2) != null) {
                    oldFamily.setCoefficient((BigDecimal) getSalesPersonTable().getTable().getValueAt(row, 2));
                }
                if (getSalesPersonTable().getTable().getValueAt(row, 1) != null) {
                    oldFamily.setDesignation((String) getSalesPersonTable().getTable().getValueAt(row, 1));
                }
                oldFamily.setUpdateUserId(param.getUserId());
                crud.update(oldFamily, 39);
                oldFamily = (Family) crud.read(oldFamily.getId(), 39);
                if (oldFamily != null) {
                    salesPersonFamilyList.set(row, oldFamily);
                }
            } else if (crud.create(39, (String) getSalesPersonTable().getTable().getValueAt(row, 0)) == null) {
                JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
                updateTable = false;
                getSalesPersonTable().getTable().setValueAt(null, row, 0);
                updateTable = true;
            } else {
                Family f = (Family) crud.read((String) getSalesPersonTable().getTable().getValueAt(row, 0), 39);
                if (f != null) {
                    if (getSalesPersonTable().getTable().getValueAt(row, 2) != null) {
                        f.setCoefficient((BigDecimal) getSalesPersonTable().getTable().getValueAt(row, 2));
                    }
                    if (getSalesPersonTable().getTable().getValueAt(row, 1) != null) {
                        f.setDesignation((String) getSalesPersonTable().getTable().getValueAt(row, 1));
                    }
                    f.setUpdateUserId(param.getUserId());
                    crud.update(f, 39);
                    f = (Family) crud.read(f.getId(), 39);
                    if (f != null) {
                        salesPersonFamilyList.set(row, f);
                    }
                    if (crud.delete(oldFamily.getId(), oldFamily.getUpdateTime(), 39)) {
                        actionCascadeUpdateSalesPerson(oldFamily.getId(), (String) getSalesPersonTable().getTable().getValueAt(row, 0));
                    }
                }
            }
        }
    }

    private void actionCascadeUpdateSalesPerson(String oldPK, String newPK) {
        crud.update(oldPK, newPK, 15);
    }

    private void actionNewSalesPersonFamily(int row) {
        if (crud.create(39, (String) getSalesPersonTable().getTable().getValueAt(row, 0)) == null) {
            JOptionPane.showMessageDialog(null, "Ce code famille existe d\351j\340 !");
            updateTable = false;
            getSalesPersonTable().getTable().setValueAt(null, row, 0);
            updateTable = true;
        } else {
            Family f = (Family) crud.read((String) getSalesPersonTable().getTable().getValueAt(row, 0), 39);
            if (f != null) {
                f.setCoefficient(new BigDecimal("0.00"));
                f.setDesignation(f.getId() + " (defaut)");
                f.setUpdateUserId(param.getUserId());
                crud.update(f, 39);
                f = (Family) crud.read(f.getId(), 39);
                if (f != null) {
                    salesPersonFamilyList.add(f);
                }
                initSalesPersonTableValues();
            }
        }
    }

    private void actionDeleteSalesPersonFamily(int row) {
        int response = JOptionPane.showConfirmDialog(null, "Etes-vous certain de vouloir suprimer cette famille ?", "Confirmation", 1, 2, null);
        switch (response) {
            case -1:
            case 0: // '\0'
            case 1: // '\001'
            case 2: // '\002'
            default:
                return;
        }
    }
    private ObjectCRUD crud;
    private Parameter param;
    private IfExist ifExist;
    private ArrayList itemFamilyList;
    private ArrayList customerFamilyList;
    private ArrayList supplierFamilyList;
    private ArrayList salesPersonFamilyList;
    private boolean updateTable;
    private boolean write;
}
